% TEST_ID: LANG-EXPAND-0110
% CATEGORY: language/string
% 测试 string 的插入

function test_string_insertBefore()
str = "bread cheese wine";
newStr = insertBefore(str," ",",");
result = ["bread, cheese, wine"];
assert(result == newStr)
assert(str == "bread cheese wine")

str = ["The quick fox jumps";"over the dog"];
newStr = insertBefore(str,[" fox";" dog"],[" brown";" lazy"]);
result = ["The quick brown fox jumps"; "over the lazy dog"];
assert(result == newStr)

str = "James Maxwell";
newStr = insertBefore(str,7,"Clerk ");
result = ["James Clerk Maxwell"];
assert(result == newStr)

str = ["James Maxwell";"Carl Gauss"];
newStr = insertBefore(str,[7;6],["Clerk ";"Friedrich "]);
result = ["James Clerk Maxwell";"Carl Friedrich Gauss"];
assert(newStr == result)

chr = 'mushrooms and onions';
newChr = insertBefore(chr,10,', peppers,');
result = ["mushrooms, peppers, and onions"];
assert(newChr == result)

chr = 'mushrooms and onions';
newChr = insertBefore(chr,' and',', peppers,');
result = ["mushrooms, peppers, and onions"];
assert(newChr == result)
end